<?php
class Modelo
{
	public function abrirConex()
	{
		$con = mysql_connect ( "localhost","root","");
		mysql_query ("SET NAMES 'utf8'");
		mysql_select_db("iatec");
		return $con;
	}

	public function cerrarConex()
	{
		mysql_close();
	}

	public function execute($query)
	{
		$this->abrirConex();
		$res = mysql_query($query);
		mysql_close();
		return $res;
	}
	
	public function comillas_inteligentes($valor){
		//retirar las barras
		if (get_magic_quotes_gpc()){
			$valor = stripslashes ($valor);
		}
		
		//colocar comillas si no es entero
		if(!is_numeric ($valor)){
			$valor = "'".mysql_real_escape_string($valor)."'";
		}
		return $valor;		
	}
	public static function ruta()
	{
		return "http://localhost/iatec/";
	}
}
?>